SetExpand

The SetExpand method sets a named value in the registry as a REG_EXPAND_SZ data type. If the key portion of the specified named value does not already exist, the SetExpand method adds that key and any specified subkeys to the registry.

Syntax

SetExpand FullKeyValueName, Value [,Flush]

Parameters

FullKeyValueName
A string that specifies the named value. This string should consist of a key name followed by a value name. For example, to specify the value MyValue stored in the key HKLM\Software\MyCompany, you would use the following string:

HKLM\Software\MyCompany\MyValue

The key portion of this parameter can be a key on either a local or a remote machine. Keys on a remote machine are specified by prefixing the key name with the machine name. For example:

\\RemoteMachine\HKLM\Software\MyProg


Value
A string that contains the data. This string can contain environment variables, such as %windir% or %PATH%.
Flush
This optional parameter is a BOOLEAN that specifies whether the registry changes that this method makes should be written to the disk immediately.

If Flush is set to TRUE, the method immediately writes the registry changes to the disk. Note that explicitly flushing registry changes to the disk may reduce server performance.

If Flush is FALSE, the method does not immediately write the registry changes to the disk. They are instead written to disk by the registry's lazy flusher or when the system shuts down.

The default is FALSE.

Example

The following example sets the named value MyPath of the key

HKLM\Software\MyCompany. Notice that the string data contains embedded environment variables, %windir% and %SystemRoot%.
<%
Set Reg = Server.CreateObject("IISSample.Registry")
MyPath = "HKLM\Software\MyCompany\MyPath"
Reg.SetExpand MyPath, "%windir%;%SystemRoot%\System32", True
Path = Reg.Get(MyPath)
PathExpand = Reg.GetExpand(MyPath)
%>
 
Path = <%= Path %> <br>
PathExpand = <%= PathExpand %> <br>
 

The above example displays the following output:
Path = %windir%;%SystemRoot%\System32 
PathExpand = D:\WINNT;D:\WINNT\System32
 

Applies To

Registry Access Component

See Also

Set, GetExpand